#!/usr/bin/env bash
# base16 ocean theme

# theme
VIM_COLORS=chameleon
BG_COMMAND="feh --bg-fill $HOME/.wm/walls/fill/ocean.jpg"

emacs_theme="base16-ocean"

# bspwm
b_border_width=6
b_window_gap=30
b_bspwmrc_extend="2bspwm &"

# panel
p_padding=3
p_window_class=noshadow
p_height=32
p_gap=0
p_underline=0
p_font_main="Droid Sans-10"
p_font_icon="FontAwesome-10"
p_desktop_display_name=name
p_desktop_show_free=false
p_desktop_only_active=true
p_title_only_show_active=true
p_bg_inactive=$p_bg_normal

st_font="Droid Sans Mono-10"

stepSetup()  {
  #togetherStep
  #reverseSteps
  separateStep
  # align is only set on sep step
  #separateStep
}

bg() {
    #step=$((step-1))
    #input="$(eval "echo \#\${color$step}")"
    input="$(gradientGet)"
    #input="$(maxchroma "$(colort -t $input)")"
    #echo "#ff$(colort -t -l -30 $input)"
    echo "$input"
}

activebg() {
    colort -l 20 "$(bg)"
}

# gradient
suffix() {
    $(iif "[ \"$lemon_target_align\" = \"right\" ]") && return

    if echo "$lemon_target" | grep -E "mpd|title" >/dev/null; then
        [ -z "$nextbg" ] && nextbg="$p_bg_normal"
    fi

    [ -z "$prevbg" ] && prevbg="$(bg)"

    if [ "${lemon_target_align}" = "left" ]; then
        step=$((step-1))
    else
        step=$((step+1));
    fi

    [ -z "$nextbg" ] && nextbg="$(bg)"

    nextbg="$(colort -t $nextbg)"
    prevbg="$(colort -t $prevbg)"

    content=""
    size=3
    IFS=$'\n'
    for color in $(gradient "$prevbg" "$nextbg" $size); do
        content="${content}%%{B#ff$(colort -t $color)} %%{B-}"
        #content="%%{B#ff$(colort -t $color)} %%{B-}${content}"
    done
    IFS=

    echo "${content}"
}

prefix() {
    $lemon_target_end && $(iif "[ \"$lemon_target_align\" = \"left\" ]") && return

    prevbg="$p_bg_normal"
    nextbg="$(bg)"
    suffix
}
